package jtest.com.cpi.cornpp.purchase.program.dao;

import com.cpi.cornpp.purchase.program.dao.PurchaseOrderChargeDAO;
import com.cpi.cornpp.purchase.program.dto.PurchaseOrderChargeDTO;
import com.cpi.cornpp.purchase.program.exception.PurchaseProgramException;

import junit.framework.TestCase;

public class PurchaseOrderChargeDAOTest extends TestCase {

	public PurchaseOrderChargeDAOTest(String name) {
		super(name);
	}

	protected void setUp() throws Exception {
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testDelete() {
		PurchaseOrderChargeDAO purchaseOrderChargeDAO = null;
		PurchaseOrderChargeDTO purchaseOrderChargeDTO = null;
		try{
			purchaseOrderChargeDAO = new PurchaseOrderChargeDAO();
			purchaseOrderChargeDTO = new PurchaseOrderChargeDTO();
			purchaseOrderChargeDTO.setPurchaseOrderId(new Integer(60));
			purchaseOrderChargeDTO.setChargeTypeId(new Integer(1));
			purchaseOrderChargeDAO.delete(purchaseOrderChargeDTO);
		}catch(PurchaseProgramException purchaseProgramException){
			fail(purchaseProgramException.getMessage());
		}
	}
	
	public void testExistsCharge(){
		PurchaseOrderChargeDAO purchaseOrderChargeDAO = null;
		PurchaseOrderChargeDTO purchaseOrderChargeDTO = null;
		boolean exists= false;
		try{
			purchaseOrderChargeDAO = new PurchaseOrderChargeDAO();
			purchaseOrderChargeDTO = new PurchaseOrderChargeDTO();
			purchaseOrderChargeDTO.setPurchaseOrderId(new Integer(60));
			purchaseOrderChargeDTO.setChargeTypeId(new Integer(1));
			exists = purchaseOrderChargeDAO.existsCharge(purchaseOrderChargeDTO);
			assertFalse(exists);
			
			purchaseOrderChargeDTO = new PurchaseOrderChargeDTO();
			purchaseOrderChargeDTO.setPurchaseOrderId(new Integer(60));
			purchaseOrderChargeDTO.setChargeTypeId(new Integer(9));
			exists = purchaseOrderChargeDAO.existsCharge(purchaseOrderChargeDTO);
			assertTrue(exists);
			
		}catch(PurchaseProgramException purchaseProgramException){
			fail(purchaseProgramException.getMessage());
		}
	}
}